package com.gcloud.mesh.dcs.strategy.huawei;



import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import com.huaweicloud.sdk.core.auth.GlobalCredentials;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.core.http.HttpConfig;
import com.huaweicloud.sdk.sms.v3.SmsClient;
import com.huaweicloud.sdk.sms.v3.model.ShowServerRequest;
import com.huaweicloud.sdk.sms.v3.model.ShowServerResponse;
import com.huaweicloud.sdk.sms.v3.region.SmsRegion;

@Component
public class ShowServerSolution {

    public static void main(String[] args) {
    	ShowServerSolution showServer = new ShowServerSolution();
    	showServer.showServer(null, null, null);
    }
    
    public ShowServerResponse showServer(String ak, String sk, String sourceId) {
    	ShowServerResponse res = null;
    	if(StringUtils.isBlank(ak)) {
     		 ak = "8QVISVT4XJHUNMIEPZBQ";
  	   	}
  	   	if(StringUtils.isBlank(sk)) {
  	   		sk = "GingsSlHInSkQ3x47jMSEjFT0uumSJgplZs926Cw";
  	   	}
  	    HttpConfig config = HttpConfig.getDefaultHttpConfig();
  	    config.withIgnoreSSLVerification(true);
        ICredential auth = new GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        SmsClient client = SmsClient.newBuilder()
        		.withHttpConfig(config)
                .withCredential(auth)
                .withRegion(SmsRegion.valueOf("ap-southeast-1"))
                .build();
        
        ShowServerRequest request = new ShowServerRequest();
        
        request.withSourceId(sourceId);
        try {
        	//Map<String, String> token = new HashMap<>();
        	//token.put("X-Auth-Token", "MIIYJQYJKoZIhvcNAQcCoIIYFjCCGBICAQExDTALBglghkgBZQMEAgEwghY3BgkqhkiG9w0BBwGgghYoBIIWJHsidG9rZW4iOnsiZXhwaXJlc19hdCI6IjIwMjEtMDQtMDlUMDk6MTY6MzguMTQwMDAwWiIsIm1ldGhvZHMiOlsicGFzc3dvcm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gwMGY2ZTBmMjdjMDAzOTkzYzllYzAifSwibmFtZSI6ImdjbG91ZGxpbmsiLCJwYXNzd29yZF9leHBpcmVzX2F0IjoiIiwiaWQiOiIwNTQ5NjE1OTVkODAyNTBmMWY4ZGMwMDMzYzI1YjkwMyJ9fX0xggHBMIIBvQIBATCBlzCBiTELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUd1YW5nRG9uZzERMA8GA1UEBwwIU2hlblpoZW4xLjAsBgNVBAoMJUh1YXdlaSBTb2Z0d2FyZSBUZWNobm9sb2dpZXMgQ28uLCBMdGQxDjAMBgNVBAsMBUNsb3VkMRMwEQYDVQQDDApjYS5pYW0ucGtpAgkA3LMrXRBhahAwCwYJYIZIAWUDBAIBMA0GCSqGSIb3DQEBAQUABIIBADP6G22kVE5dhmSXlNSNTccZAez8VvyHxur-XZ-x8jquLWMDso4kQE0W-3nBbcA5-OwJuhPU0LolhZJLyaG8MgNRinQk7QaS3NV+euh666FgzS7Nqziq7XteNeYK9iujklXfbSzZ8jKwsyjkDiVKi8O4NSeBKMA1QV6Ts0gn3LfHCAb8vbvD1nLfrRphZgjjHQtWsqgmkOm9Dab2zx41iJiY2YVjlZnnNhJElaR8WNHwffv3hZpGBOpz6yFmQAYR-VSPeUUS9avuDr4jgbf+zsTy6+4-LjlyNmwC256rYCchoH9QZGdqaNkE+OIKtdvJUkwI3xAxstc2YKxm-ZP6kwI=");
        	// SyncInvoker<ShowServerRequest, ShowServerResponse> response = client.showServerInvoker(request);
        	//String res = HttpClientUtil.doGet("https://sms.ap-southeast-1.myhuaweicloud.com/v3/tasks/930372ff-ebc5-4e36-a0c7-5beb8131c3a7",null , token);
        	//ShowServerResponse res = response.invoke();
        	res = client.showServer(request);
 //       	System.out.println(res.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
//            System.out.println(e.getHttpStatusCode());
//            System.out.println(e.getErrorCode());
//            System.out.println(e.getErrorMsg());
        }
        return res;
    }
}